
import fs from 'fs'

function getFile(fpath) {
  return new Promise(function(resolve, reject){
    fs.readFile(fpath, 'utf8', (err, dataStr) => {

      if (err)
        return reject(err)
      resolve(dataStr)

      // console.log(dataStr)
    })  //'./files/001.txt'
  })
}

getFile('./files/001.txt').then((data)=>{
  console.log(data)
}, (err)=>{
  console.log(err.message)
}).catch((err)=>{
  console.log(err)
})
